package cn.bgs.service.impl;

import cn.bgs.Exception.PhoenixException;
import cn.bgs.dao.RoomMapper;
import cn.bgs.pojo.ClassRoom;

import cn.bgs.pojo.Student;
import cn.bgs.pojo.VoAll.ClassRoomVo;
import cn.bgs.service.RoomService;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author Mr.JIA
 * @DATE 2021/7/26 0026 9:38
 * @PROJECT_NAME mybatis_phoenix
 * @PACKAGE_NAME cn.bgs.service.impl
 */
@Service
public class RoomServiceImpl implements RoomService {

    Logger log = LogManager.getLogger();

    @Autowired
    private RoomMapper roomMapper;


    @Override
    public List<Student> findAllRoom(ClassRoomVo vo) {
        return roomMapper.findAllRoom(vo);
    }

    @Override
    public Integer delRoom(int pkId) {
        return roomMapper.delRoom(pkId);
    }

    @Override
    public Integer addRoom(ClassRoom ro) {
        return roomMapper.addRoom(ro);
    }

    @Override
    public Integer updateRoom(ClassRoom cc) throws PhoenixException {
        try{
            return roomMapper.updateRoom(cc);
        }catch (Exception e){
            log.error("roomMapper.updateRoom:::::::::"+cc);
            log.error("123::::::::::::"+e.getMessage());    //方法错误的信息
            e.printStackTrace();    //异常的信息   打印堆栈跟踪
            throw new PhoenixException("9999","修改失败");
        }
    }

    @Override
    public List<ClassRoom> findArea() {
        return roomMapper.findArea();
    }

    @Override
    public List<ClassRoom> findBuildingNo(String buildingNo) {
        return roomMapper.findBuildingNo(buildingNo);
    }

    @Override
    public List<ClassRoom> findBuildingFloor(String floor,String no) {
        return roomMapper.findBuildingFloor(floor,no);
    }


}
